// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
// Distributable under LGPL license. See terms of license at gnu.org.

package nl.justobjects.pushlet.core;

/**
 * Logging utility.
 * TODO - use Log4J
 *
 * @author Just van den Broecke
 * @version $Id: Log.java,v 1.4 2003/08/15 09:54:46 justb Exp $
 */
public class Log {

	private static boolean debug = false;

	/**
	 * Enable/disable debug logging.
	 *
	 * @param b on (true) off (false)
	 */
	static public void setDebug(boolean b) {
		debug = b;
	}

	/**
	 * Log message for debug level.
	 *
	 * @param aMessage the message to be logged
	 */
	static public void debug(String aMessage) {
		if (debug) {
			print("DEBUG", aMessage);
		}
	}

	/**
	 * Log message for info level.
	 *
	 * @param aMessage the message to be logged
	 */
	static public void info(String aMessage) {
		print("INFO", aMessage);
	}

	/**
	 * Log message for warning level.
	 *
	 * @param aMessage the message to be logged
	 */
	static public void warn(String aMessage) {
		print("WARN", aMessage);
	}

	/**
	 * Log message for warning level with exception.
	 *
	 * @param aMessage the message to be logged
	 * @param aThrowable the exception
	 */
	static public void warn(String aMessage, Throwable aThrowable) {
		warn(aMessage + " exception=" + aThrowable);
	}

	/**
	 * Log message for fatal level.
	 *
	 * @param aMessage the message to be logged
	 */
	static public void fatal(String aMessage) {
		print("FATAL", aMessage);
	}

		/**
	 * Log message (fatal level with exception).
	 *
	 * @param aMessage the message to be logged
	 * @param aThrowable the exception
	 */
	static public void fatal(String aMessage, Throwable aThrowable) {
		fatal(aMessage + " exception=" + aThrowable);
	}
	/**
	 * Print message.
	 *
	 * @param aLogLevel the log level
	 * @param aMessage the message to be logged
	 */
	static private void print(String aLogLevel, String aMessage) {
		// For now...
		System.out.println("Pushlet[" + aLogLevel + "] " + aMessage);
	}

}

/*
* $Log: Log.java,v $
* Revision 1.4  2003/08/15 09:54:46  justb
* fix javadoc warnings
*
* Revision 1.3  2003/08/15 08:37:40  justb
* fix/add Copyright+LGPL file headers and footers
*
* Revision 1.2  2003/08/12 09:42:47  justb
* enhancements
*
* Revision 1.1  2003/08/12 08:46:00  justb
* cvs comment tags added
*
*
*/